"use strict";
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
    if (kind === "m") throw new TypeError("Private method is not writable");
    if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
    if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
    return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
};
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
    if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
    if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
    return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
};
var _Child_name;
function helloWorld() {
    console.log('helloWorld');
}
helloWorld();
// 基本类型
// boolean类型
let tru = false;
console.log(tru);
// 数字类型
let count = 20;
console.log(count);
// 字符串类型
let str = 'yhx';
console.log(str);
// Symbol类型
const sym = Symbol();
let obj = {
    [sym]: 'Semlinker'
};
console.log(obj[sym]);
// Array类型
let list = ['1', '2', '3'];
let list2 = [1, 2, 3]; //Array<number>泛型语法
// Enum类型  枚举可以定义一些带数字的常量
// 数字枚举   不赋值时默认从0开始 赋值后默认增加
var Direction;
(function (Direction) {
    Direction[Direction["a"] = 3] = "a";
    Direction[Direction["b"] = 4] = "b";
    Direction[Direction["c"] = 5] = "c";
    Direction[Direction["d"] = 6] = "d";
})(Direction || (Direction = {}));
let dir = Direction.a;
console.log(dir);
console.log(Direction.b);
// 字符串枚举
var Strection;
(function (Strection) {
    Strection["a"] = "1";
    Strection["b"] = "2";
    Strection["c"] = "3";
})(Strection || (Strection = {}));
let str2 = Strection.a;
console.log(str2);
const con = 0 /* a */;
console.log(con);
// 异构枚举  成员值是数字和字符串的结合
var Enum;
(function (Enum) {
    Enum[Enum["A"] = 0] = "A";
    Enum[Enum["B"] = 1] = "B";
    Enum["C"] = "C";
    Enum[Enum["D"] = 8] = "D";
    Enum[Enum["E"] = 9] = "E";
})(Enum || (Enum = {}));
console.log(Enum.A); // 0
console.log(Enum[0]); //A  //数字枚举相对字符串枚举多了 “反向映射”：
// any类型 任何类型都可以为any类型
let notSure = '222';
notSure = 1,
    notSure = false;
notSure = ['1', '2'];
console.log(notSure);
// 元组类型  单个变量中存储不同类型的值
let tupleType = ['111', false];
console.log(tupleType[1]);
// void类型与any类型相反当一个函数没有返回值时，通常会见到返回值为void
function WarnUser() {
    console.log('你错拉吗');
}
WarnUser();
// null 和 undefined
let u = undefined;
let n = null;
// 对象类型
let obj1 = {
    name: 'yxh'
};
console.log(obj1);
// never类型 永不存在的值
// 类型断言（两种形式）
// 1.<>尖括号用法
// let someVale:any = "this is a String"
// let strLength:number = (<string>someVale).length
// console.log(someVale,strLength)
// 2.as用法
let someVale = "this is a String";
let strLength = someVale.length;
console.log(someVale, strLength);
// 确定赋值断言
let x;
addx();
console.log(2 + x);
function addx() {
    x = 10;
}
const EVALUATION_FACTOR = Math.PI;
function evaluatePrice(vehicle) {
    switch (vehicle.vType) {
        case "car":
            return vehicle.age * EVALUATION_FACTOR;
        case "truck":
            return vehicle.capacity * EVALUATION_FACTOR;
        case "motorcycle":
            return vehicle.make * EVALUATION_FACTOR;
    }
}
console.log(EVALUATION_FACTOR);
const myTruck = { vType: "truck", capacity: 12 };
console.log(evaluatePrice(myTruck));
console.log(evaluatePrice({ vType: 'car', age: 12 }));
let greet = (message) => { };
let po = {
    x: 1,
    y: 2,
};
console.log(po);
let abc = {
    x: {
        d: true,
        e: 'semlinker',
        f: 666
    }
};
console.log('abc:', abc);
// typeScript函数
// 箭头函数
// var publishDate:number
function Book() {
    // console.log(this)
    // this.publishDate = 2016;
    // setInterval(() => {
    //   console.log(this.publishDate);
    // }, 1000);
}
Book();
// let IdGenerator: (chars: string, nums: number) => string;
// function create(name:string,id:number):string{
//     return name + id
// }
// IdGenerator = create;
// console.log( create('yhx',20) )
// console.log( IdGenerator )
// 可选参数和默认参数
function create(name, id, age) {
    return name + id;
}
function create2(name = 'yhx', id, age) {
    return name + id;
}
// 剩余参数
function push(qwe, ...items) {
    items.forEach(function (item) {
        qwe.push(item);
    });
}
let arr = [];
push(arr, 1, 2, 3);
console.log(arr, '剩余参数');
let p1 = {
    name: 'yhx',
};
console.log(p1);
let a = [1, 2, 3, 4];
let ro = a;
console.log(a[0], ro);
const p2 = { name: "semlinker" };
const p3 = { name: "lolo", age: 5 };
const p4 = { name: "kakuqo", sex: 1 };
console.log(p2, p3, p4);
console.log();
class o1 {
    constructor() {
        this.x = 1;
        this.y = 1;
    }
}
// 报错
// type PartialPoint = { x: number; } | { y: number; };
// class o12 implements PartialPoint{
//     x=1;
//     y=1
// }
// 类的私有属性
// class Child {
//     #name:string;
//     constructor(name:string){
//         this.#name = name
//     }
//     greet(){
//         console.log( `heelo,my name is ${this.#name}`)
//     }
// }
// let chi = new Child('王燕南')
// chi.greet()
// chi.#name
// let passcode = "Hello TypeScript";
// class Animal {
//     constructor(name:string) {
//       this.name = name;
//     }
//     get name() {
//       return 'Jack';
//     }
//     set name(value) {
//       console.log('setter: ' + value);
//     }
//   }
// let a2 = new Animal('Kitty'); // setter: Kitty
// a2.name = 'Tom'; // setter: Tom
// console.log(a2.name); // Jack
// // 类的继承
// class Animla {
//     name:string;
//     constructor(name:string){
//         this.name = name
//     }
//     sayHi(){
//         return `my name is ${this.name}`
//     }
// }
// let an = new Animla('熊猫')
// console.log( an.sayHi())
// class Cart extends Animla {
//     constructor(name:string){   
//         super(name);        //调用父类的constructor
//         console.log(this.name)
//     }
//     sayHi(): string {
//         return '继承' + super.sayHi() //调用父类的sayHi
//     }
// }
// let c = new Cart('猫咪')
// console.log(c.sayHi())
// 类的修饰符
class Child {
    constructor(name) {
        _Child_name.set(this, void 0);
        __classPrivateFieldSet(this, _Child_name, name, "f");
    }
    greet() {
        console.log(`heelo,my name is ${__classPrivateFieldGet(this, _Child_name, "f")}`);
    }
}
_Child_name = new WeakMap();
let chi = new Child('王燕南');
// chi.greet() //报错 prot修饰的只有在子类中可以访问
class Yhx extends Child {
    send() {
        super.greet();
    }
}
let yh = new Yhx('hhaha');
yh.send(); //heelo,my name is hhaha
class Cartt {
    alert() {
        console.log('Cartt alert');
    }
    lightOn() {
        console.log('Cartt light on');
    }
    lightOff() {
        console.log('Cartt light off');
    }
}
let carr = new Cartt();
carr.alert();
carr.lightOn();
// console.log(carr)
// type aaa = {
//     x:number
// }
// let a3:aaa = {
//     x:1
// }
// console.log(a3)
// 泛型 在定义函数、接口、类的时候，不预先指定具体的类型，而在使用的时候再指定类型的一种特性
// Array<any>  数组泛型
// function creatApp(length:number,value:any):Array<any>{
//     let result = []
//     for(let i = 0;i<length; i++){
//         result[i] = value
//     }
//     return result
// }
// let res = creatApp(2,2)
// console.log( res )
// T用来指任意类型 在调用的时候指定他的类型  也可以不指定默认推算出来
function creatApp(length, value) {
    let result = [];
    for (let i = 0; i < length; i++) {
        result[i] = value;
    }
    return result;
}
let res = creatApp(2, '1');
console.log(res);
// 定义多个类型参数
function createVue(value, message) {
    console.log(message);
    return value;
}
console.log(createVue('yhx', 1));
console.log(createVue('yhx', 1));
function createFan(val, meg) {
    console.log(val + ":" + typeof (val)); //   1:number 
    console.log(meg + ":" + typeof (meg)); //   2:number
    let idens = {
        val,
        meg
    };
    return idens;
}
console.log(createFan(1, 2)); // {val: 1, meg: 2}
